package com.td.module.agro.dal.mysql.review;

import com.td.framework.common.pojo.PageResult;
import com.td.framework.mybatis.core.mapper.BaseMapperX;
import com.td.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.td.module.agro.controller.admin.review.vo.ReviewExportReqVO;
import com.td.module.agro.controller.admin.review.vo.ReviewPageReqVO;
import com.td.module.agro.dal.dataobject.review.ReviewDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 溯源信息 Mapper
 *
 * @author 吴佰强
 */
@Mapper
public interface ReviewMapper extends BaseMapperX<ReviewDO> {

    default PageResult<ReviewDO> selectPage(ReviewPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReviewDO>()
                .eqIfPresent(ReviewDO::getPollingType, reqVO.getPollingType())
                .likeIfPresent(ReviewDO::getAgroProductName, reqVO.getAgroProductName())
                .eqIfPresent(ReviewDO::getAgroProductType, reqVO.getAgroProductType())
                .eqIfPresent(ReviewDO::getAgroProductDescribe, reqVO.getAgroProductDescribe())
                .eqIfPresent(ReviewDO::getAgroProductOrigin, reqVO.getAgroProductOrigin())
                .eqIfPresent(ReviewDO::getAgroProductManufacturer, reqVO.getAgroProductManufacturer())
                .eqIfPresent(ReviewDO::getAgroProductPrice, reqVO.getAgroProductPrice())
                .eqIfPresent(ReviewDO::getAgroProductWeight, reqVO.getAgroProductWeight())
                .eqIfPresent(ReviewDO::getStorageMethod, reqVO.getStorageMethod())
                .eqIfPresent(ReviewDO::getPackagingMethod, reqVO.getPackagingMethod())
                .betweenIfPresent(ReviewDO::getStorageTime, reqVO.getStorageTime())
                .betweenIfPresent(ReviewDO::getProduceDate, reqVO.getProduceDate())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringType, reqVO.getEnvironmentMonitoringType())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringMethod, reqVO.getEnvironmentMonitoringMethod())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringPerson, reqVO.getEnvironmentMonitoringPerson())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringResult, reqVO.getEnvironmentMonitoringResult())
                .betweenIfPresent(ReviewDO::getEnvironmentMonitoringStartTime, reqVO.getEnvironmentMonitoringStartTime())
                .betweenIfPresent(ReviewDO::getEnvironmentMonitoringEndTime, reqVO.getEnvironmentMonitoringEndTime())
                .eqIfPresent(ReviewDO::getProduceVideoMonitorUrl, reqVO.getProduceVideoMonitorUrl())
                .betweenIfPresent(ReviewDO::getProduceVideoMonitorTime, reqVO.getProduceVideoMonitorTime())
                .eqIfPresent(ReviewDO::getQualityTestOrganization, reqVO.getQualityTestOrganization())
                .eqIfPresent(ReviewDO::getQualityTestPerson, reqVO.getQualityTestPerson())
                .eqIfPresent(ReviewDO::getQualityTestMethod, reqVO.getQualityTestMethod())
                .eqIfPresent(ReviewDO::getQualityTestProjectBasis, reqVO.getQualityTestProjectBasis())
                .eqIfPresent(ReviewDO::getQualityTestResult, reqVO.getQualityTestResult())
                .betweenIfPresent(ReviewDO::getQualityTestSamplingTime, reqVO.getQualityTestSamplingTime())
                .betweenIfPresent(ReviewDO::getQualityTestTime, reqVO.getQualityTestTime())
                .betweenIfPresent(ReviewDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReviewDO::getId));
    }

    default List<ReviewDO> selectList(ReviewExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ReviewDO>()
                .eqIfPresent(ReviewDO::getPollingType, reqVO.getPollingType())
                .likeIfPresent(ReviewDO::getAgroProductName, reqVO.getAgroProductName())
                .eqIfPresent(ReviewDO::getAgroProductType, reqVO.getAgroProductType())
                .eqIfPresent(ReviewDO::getAgroProductDescribe, reqVO.getAgroProductDescribe())
                .eqIfPresent(ReviewDO::getAgroProductOrigin, reqVO.getAgroProductOrigin())
                .eqIfPresent(ReviewDO::getAgroProductManufacturer, reqVO.getAgroProductManufacturer())
                .eqIfPresent(ReviewDO::getAgroProductPrice, reqVO.getAgroProductPrice())
                .eqIfPresent(ReviewDO::getAgroProductWeight, reqVO.getAgroProductWeight())
                .eqIfPresent(ReviewDO::getStorageMethod, reqVO.getStorageMethod())
                .eqIfPresent(ReviewDO::getPackagingMethod, reqVO.getPackagingMethod())
                .betweenIfPresent(ReviewDO::getStorageTime, reqVO.getStorageTime())
                .betweenIfPresent(ReviewDO::getProduceDate, reqVO.getProduceDate())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringType, reqVO.getEnvironmentMonitoringType())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringMethod, reqVO.getEnvironmentMonitoringMethod())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringPerson, reqVO.getEnvironmentMonitoringPerson())
                .eqIfPresent(ReviewDO::getEnvironmentMonitoringResult, reqVO.getEnvironmentMonitoringResult())
                .betweenIfPresent(ReviewDO::getEnvironmentMonitoringStartTime, reqVO.getEnvironmentMonitoringStartTime())
                .betweenIfPresent(ReviewDO::getEnvironmentMonitoringEndTime, reqVO.getEnvironmentMonitoringEndTime())
                .eqIfPresent(ReviewDO::getProduceVideoMonitorUrl, reqVO.getProduceVideoMonitorUrl())
                .betweenIfPresent(ReviewDO::getProduceVideoMonitorTime, reqVO.getProduceVideoMonitorTime())
                .eqIfPresent(ReviewDO::getQualityTestOrganization, reqVO.getQualityTestOrganization())
                .eqIfPresent(ReviewDO::getQualityTestPerson, reqVO.getQualityTestPerson())
                .eqIfPresent(ReviewDO::getQualityTestMethod, reqVO.getQualityTestMethod())
                .eqIfPresent(ReviewDO::getQualityTestProjectBasis, reqVO.getQualityTestProjectBasis())
                .eqIfPresent(ReviewDO::getQualityTestResult, reqVO.getQualityTestResult())
                .betweenIfPresent(ReviewDO::getQualityTestSamplingTime, reqVO.getQualityTestSamplingTime())
                .betweenIfPresent(ReviewDO::getQualityTestTime, reqVO.getQualityTestTime())
                .betweenIfPresent(ReviewDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReviewDO::getId));
    }

}
